| 
ContentsListsList literalsA list with a constant length can be written by closing the list elements in brackets and separating the elements by commas: 
List comprehensionLists can be formed with list comprehension expressions that resemble set comprehension in mathematics. For example 
creates a list of all elements in  
creates list of all sums of pairs where one element is in  It is possible to add also constraints 
and definitions 
Formally, a list comprehension expression is 
where list qualifier can be one of the following 
 The last type of qualifier can be used to make operations that affects the whole list, for example 
removes the first three elements and 
sorts the elements by  Accessing the list elementsThe most basic way of reading list is to read it element by element. (!) :: IndexedSequence a => a b -> Integer -> b (Prelude) 
 length :: Sequence a => a -> Integer (Prelude) Length of the sequence ComparisonLists like almost all other types support the generic equality and comparison operations: 
(!=) :: a -> a -> Boolean (Prelude) (<) :: Ord a => a -> a -> Boolean (Prelude) Less (<=) :: Ord a => a -> a -> Boolean (Prelude) Less or equal (>) :: Ord a => a -> a -> Boolean (Prelude) Greater (>=) :: Ord a => a -> a -> Boolean (Prelude) Greater or equal For example  Executing code for each list elementThe only difference between the following iteration functions is the order of their parameters: iter :: FunctorE a => (b -> <d> c) -> a b -> <d> () (Prelude) Calls the given function with all elements of the given container. for :: FunctorE a => a b -> (b -> <d> c) -> <d> () (Prelude) Iterates the elements of the given collection. Same as  Concatenating lists(+) :: Additive a => a -> a -> a (Prelude) Adds two objects (numbers, vectors, strings, etc.) together. sum :: Additive a => [a] -> a (Prelude) Sum of the elements: 
Implemented usually more efficiently than with repetitive
application of  List transformationsmap :: FunctorE a => (b -> <d> c) -> a b -> <d> a c (Prelude) Applies the function to all elements of the container and returns the similarly shaped container with the results: For lists, 
for example 
filter :: MonadZeroE a => (b -> <c> Boolean) -> a b -> <c> a b (Prelude) join :: Monad a => a (a b) -> a b (Prelude) The join function is the conventional monad join operator. It removes one level of monadic structure. For lists,  
concatMap :: (a -> <c> [b]) -> [a] -> <c> [b] (Prelude) 
 
mapMaybe :: (a -> <c> Maybe b) -> [a] -> <c> [b] (Prelude) 
 
zip :: [a] -> [b] -> [(a, b)] (Prelude) Combines two lists into one list of pairs. The length of the resulting list is the length of the smallest input list. 
zipWith :: (a -> b -> <d> c) -> [a] -> [b] -> <d> [c] (Prelude) Combines two lists by using the given function for combining the elements. The length of the resulting list is the length of the smallest input list. unzip :: [(a, b)] -> ([a], [b]) (Prelude) Produces two lists from one list of pairs. 
OrderingThe following functions modify the order of the list elements: sort :: Ord a => [a] -> [a] (Prelude) Sorts the given list using its default order. sortBy :: Ord a => (b -> <c> a) -> [b] -> <c> [b] (Prelude) Sorts the lists by the values computed by the first function. For example 
sortWith :: (a -> a -> <b> Integer) -> [a] -> <b> [a] (Prelude) Sorts the list using the given comparator. reverse :: [a] -> [a] (Prelude) Reverses a given list. For example,  SublistsThe following functions extract some sublist of the given list: take :: Sequence a => Integer -> a -> a (Prelude) 
 drop :: Sequence a => Integer -> a -> a (Prelude) 
 sub :: Sequence a => a -> Integer -> Integer -> a (Prelude) 
 Aggregate operationsSometimes it is necessary to compute some kind of summary over
all elements of a list. The most useful generic aggregate operation is  foldl :: (a -> b -> <c> a) -> a -> [b] -> <c> a (Prelude) 
applies a binary operator  
It is used to define many more specialized aggreate operations such as 
There is a variant that traverses the list from right to left: foldr :: (a -> b -> <c> b) -> b -> [a] -> <c> b (Prelude) 
 and a variant that that assumes that the list has at least one element: foldl1 :: (a -> a -> <b> a) -> [a] -> <b> a (Prelude) Like   |